package com.hqd.ch03.v16.aop.config;

import com.hqd.ch03.v16.config.BeanDefinition;
import com.hqd.ch03.v16.reader.xml.parse.BeanDefinitionParser;
import com.hqd.ch03.v16.utils.DomUtils;
import org.w3c.dom.Element;

import java.util.List;

public class ConfigBeanDefinitionParser implements BeanDefinitionParser {
    private static final String ASPECT = "aspect";
    private static final String EXPRESSION = "expression";
    private static final String ID = "id";
    private static final String POINTCUT = "pointcut";
    private static final String ADVICE_BEAN_NAME = "adviceBeanName";
    private static final String ADVISOR = "advisor";
    private static final String ADVICE_REF = "advice-ref";
    private static final String POINTCUT_REF = "pointcut-ref";
    private static final String REF = "ref";
    private static final String BEFORE = "before";
    private static final String DECLARE_PARENTS = "declare-parents";
    private static final String TYPE_PATTERN = "types-matching";
    private static final String DEFAULT_IMPL = "default-impl";
    private static final String DELEGATE_REF = "delegate-ref";
    private static final String IMPLEMENT_INTERFACE = "implement-interface";
    private static final String AFTER = "after";
    private static final String AFTER_RETURNING_ELEMENT = "after-returning";
    private static final String AFTER_THROWING_ELEMENT = "after-throwing";
    private static final String AROUND = "around";
    private static final String RETURNING = "returning";
    private static final String RETURNING_PROPERTY = "returningName";
    private static final String THROWING = "throwing";
    private static final String THROWING_PROPERTY = "throwingName";
    private static final String ARG_NAMES = "arg-names";
    private static final String ARG_NAMES_PROPERTY = "argumentNames";
    private static final String ASPECT_NAME_PROPERTY = "aspectName";
    private static final String DECLARATION_ORDER_PROPERTY = "declarationOrder";
    private static final String ORDER_PROPERTY = "order";

    @Override
    public BeanDefinition parse(Element element) {
        // configureAutoProxyCreator(parserContext, element);

        List<Element> childElements = DomUtils.getChildElements(element);
        childElements.forEach(child -> {
            String localName = child.getLocalName();
            //解析切点
            if (POINTCUT.equals(localName)) {
                //    parsePointcut(elt, parserContext);
            } else if (ADVISOR.equals(localName)) {//解析切面
                //  parseAdvisor(elt, parserContext);
            } else if (ASPECT.equals(localName)) {//解析通知
                // parseAspect(elt, parserContext);
            }
        });
        return null;
    }
}
